package main;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class test1 {
	public static void main(String[] args) {
		t2();
		t1();
	}
	private static void t2() {
		String input="248,259,258,267,275,279,285,296,298,302,305,306,315,304,285,281,267,260,264,263,263,269,291,314,320,321,298,299,278,283,291,295,253,248,270,268,282,284,312,324,325,307,312,306,332,331,307,292,274,279,270,264,261,267,312,323,330,325,295,280,284,273,280,289,244,261,272,281,307,329,342,345,328,304,325,312,334,344,343,344,340,299,290,273,291,309,330,333,320,327,276,271,278,285,275,285,262,259,283,272,326,329,350,344,321,324,318,335,340,333,348,340,342,339,300,288,313,314,337,330,320,317,282,273,268,274,286,284,263,267,285,289,331,336,337,340,324,329,329,337,339,338,335,345,335,346,333,334,340,333,332,331,323,314,273,271,256,271,276,288,261,261,281,299,333,336,345,334,328,328,330,335,334,324,340,331,344,339,342,340,331,337,338,335,321,301,279,265,272,278,287,280,260,264,282,305,336,327,334,333,330,333,331,336,332,329,336,333,341,340,339,343,341,333,331,334,314,307,283,282,273,272,282,293,264,255,288,306,335,327,337,333,331,330,335,332,338,328,341,339,341,336,342,344,339,336,333,337,320,315,298,289,290,284,293,291,262,259,284,308,333,332,340,337,327,330,332,337,336,332,334,337,342,341,337,344,339,333,331,335,328,331,329,330,320,324,321,313,260,256,281,293,326,328,342,328,331,326,339,328,341,335,342,338,341,338,344,346,336,331,335,337,337,323,329,329,328,328,332,314,259,263,267,278,307,314,324,328,310,322,322,327,331,339,337,345,339,340,334,343,333,343,335,335,326,330,333,334,328,327,336,330,260,258,265,265,275,291,325,328,301,304,321,324,338,335,343,333,338,337,344,343,340,341,339,336,332,327,334,324,331,327,327,327,264,270,265,271,264,266,270,279,282,283,308,316,317,319,334,333,341,342,348,355,347,340,335,337,335,328,338,329,317,324,322,330,272,268,276,272,269,270,278,280,280,277,283,287,306,309,332,337,342,339,352,346,344,338,344,334,327,329,335,324,329,319,324,319,276,275,280,277,280,275,274,282,279,281,280,287,274,279,317,331,332,342,342,350,338,337,336,333,330,329,324,331,321,318,322,328,282,265,280,276,280,271,283,274,278,278,285,277,280,275,307,321,340,340,346,340,343,333,332,336,332,325,327,326,327,321,329,318,272,266,277,280,276,276,277,287,277,281,278,278,277,278,288,307,335,333,332,334,327,334,327,332,326,329,319,325,326,326,317,330,270,269,283,281,281,275,279,282,286,278,287,279,278,280,291,296,332,325,333,331,323,319,334,332,329,325,329,324,322,321,322,318,272,272,269,288,276,275,279,279,281,285,289,278,276,271,283,294,321,322,321,329,326,325,326,333,325,327,321,326,318,323,323,318,270,259,281,280,277,273,284,282,282,284,284,284,277,278,287,289,318,322,331,328,325,323,330,331,325,323,323,315,318,317,324,313,265,277,280,279,280,281,278,275,281,280,279,278,279,276,279,282,309,316,320,325,320,328,324,331,318,323,326,325,306,316,320,317,274,267,287,285,280,271,281,276,280,279,283,283,282,276,279,277,301,306,323,321,323,319,326,324,323,320,316,320,309,315,323,325,266,273,274,285,276,276,273,282,280,282,283,280,275,272,282,278,280,279,305,312,310,323,320,319,321,314,314,322,316,317,322,320,270,273,278,277,276,277,287,285,283,287,288,280,278,274,283,280,278,281,288,297,313,311,318,319,314,316,326,318,314,312,319,325,";
		System.out.println(formatThermalData(input,24,32));
	}
    private static String formatThermalData(String input, int rows, int cols) {
    	if(input==null || input.length()==0)
    		return null;
        String[] tokens = input.split(",");
        if(tokens.length!=24*32)
        	return null;
        StringBuilder sb = new StringBuilder();
        sb.append("[").append(" ");

        for (int i = 0; i < rows; i++) {
            sb.append(" (");
            for (int j = 0; j < cols; j++) {
                int index = i * cols + j;
                if (j > 0) sb.append(", ");
                sb.append(Integer.parseInt(tokens[index]) / 10.0f);
            }
            sb.append(")");
            if (i < rows - 1) sb.append(",");
            sb.append(" ");
        }

        sb.append("]");
        return sb.toString();
    }
	private static void t1() {
        String[] testCases = {
            "module_camera.content(100-200)",
            "test.modulea(42)",
            "test.moduleb",
            "invalid_format[100]",
            "missing.parens100",
            "empty.parens()"
        };

        // 正则表达式匹配模式（支持可选括号）
        //String regex = "(\\w+.\\w+)(\\d+)?";
        //String regex = "^([\\w.]+)\\$(\\d+)\\$";
        String regex = "([\\w.]+)\\s*(?:\\((\\s*\\d+-?\\d+?\\s*)\\))?";
        Pattern pattern = Pattern.compile(regex);

        for (String input : testCases) {
            Matcher matcher = pattern.matcher(input);
            if (matcher.matches()) {
                String moduleName = matcher.group(1);
                String number= matcher.group(2);  // 可能为null
                
                System.out.println("输入: " + input);
                System.out.println("模块名: " + moduleName);
                System.out.println("数字: " + (number != null ? number : "无"));
                System.out.println("------------------");
            } else {
                System.out.println("输入: " + input + " → 格式不匹配\n------------------");
            }
        }
    }
}
